package com.bigdata.service.controller.app;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import com.bigdata.common.annotation.Log;
import com.bigdata.common.annotation.RepeatSubmit;
import com.bigdata.common.core.controller.BaseController;
import com.bigdata.common.core.domain.PageQuery;
import com.bigdata.common.core.domain.R;
import com.bigdata.common.core.page.TableDataInfo;
import com.bigdata.common.core.validate.AddGroup;
import com.bigdata.common.core.validate.EditGroup;
import com.bigdata.common.enums.BusinessType;
import com.bigdata.common.utils.poi.ExcelUtil;
import com.bigdata.service.domain.bo.DataCategoriesBo;
import com.bigdata.service.domain.vo.DataCategoriesVo;
import com.bigdata.service.service.IDataCategoriesService;
import com.bigdata.service.service.IDatasetsService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 数据分类
 *
 * @author ruoyi
 * @date 2025-07-15
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/service/categories")
public class AppDataCategoriesController extends BaseController {

    private final IDataCategoriesService iDataCategoriesService;

    private final IDatasetsService iDatasetsService;

    /**
     * 查询数据分类列表
     */
    @SaIgnore
    @PostMapping("/list")
    public TableDataInfo<DataCategoriesVo> list(@RequestBody DataCategoriesBo bo) {
        PageQuery pageQuery = new PageQuery();
        pageQuery.setPageNum(bo.getPageNum());
        pageQuery.setPageSize(bo.getPageSize());

        TableDataInfo<DataCategoriesVo> dataInfo = iDataCategoriesService.queryPageList(bo, pageQuery);
//        dataInfo.getRows().forEach(item -> {
//            int num = iDatasetsService.queryCategoriesNum(item.getId()).intValue();
//            item.setName(item.getName()+ "("+num+")");
//            item.setCategoriesNum(num);
//        });
        return dataInfo;
    }


}
